<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>血小板</title>

    <link href="css/style.css" rel="stylesheet">
</head>
<body>
<h3>领个血小板到自己的博客吧</h3>
<p>
    原作者:<a href="https://imjad.cn/" target="_blank">@猫与向日葵</a><br>
    参考他的若干文章:<br>
    <a href="https://imjad.cn/archives/lab/add-dynamic-poster-girl-with-live2d-to-your-blog-01" target="_blank">给博客添加能动的看板娘(Live2D)-关于模型的二三事</a><br>
    <a href="https://imjad.cn/archives/lab/add-dynamic-poster-girl-with-live2d-to-your-blog-02" target="_blank">给博客添加能动的看板娘(Live2D)-将其添加到网页上吧</a><br>
    <a href="https://imjad.cn/archives/lab/add-dynamic-poster-girl-with-live2d-to-your-blog-03" target="_blank">给博客添加能动的看板娘(Live2D)-模型格式v3转v2</a><br>
    本站源码:<a href="https://gitee.com/tczmh/xuexiaoban" target="_blank">https://gitee.com/tczmh/xuexiaoban</a>
</p>
<!--<div id="xuexiaoban">-->
<!--<div id="xuexiaoban-tips"></div>-->
<!--<canvas id="live2d" class="live2d" width="350" height="350"></canvas>-->
<!--</div>-->
<script src="js/live2d.js"></script>
<script type="text/javascript">

    let xuexiaoban = document.createElement('div');
    let xuexiaobanTips = document.createElement('div');
    let live2d = document.createElement('canvas');
    xuexiaoban.id = 'xuexiaoban';
    xuexiaobanTips.id = 'xuexiaoban-tips';
    live2d.id = 'live2d';
    live2d.class = 'live2d';
    live2d.width = '350';
    live2d.height = '350';
    xuexiaoban.appendChild(xuexiaobanTips);
    xuexiaoban.appendChild(live2d);
    document.body.appendChild(xuexiaoban);

    // loadlive2d("live2d", "https://cdn1.zzzmh.cn/live2DModel/xxb/model.json");
    loadlive2d("live2d", "live2d/xxb/model.json");
    window.onload = function () {
        message("啊~牙白~被发现了呢");
    }

    function message(text, timeout) {
        document.getElementById('xuexiaoban-tips').innerText = text;
        document.getElementById('xuexiaoban-tips').style.opacity = '1';
        if (!timeout) timeout = 5000;
        setTimeout(function () {
            document.getElementById('xuexiaoban-tips').style.opacity = '0';
            setTimeout(function () {
                message(yiyan());
            }, timeout);
        }, timeout);
    }

    function yiyan() {
        let xhr = new XMLHttpRequest();
        xhr.open('get', 'https://v1.hitokoto.cn/?c=b&encode=text&charset=utf-8', false);
        xhr.send(null);
        if (xhr.readyState == 4 && xhr.status == 200) {
            return xhr.responseText;
        } else {
            return "什么破网络啊~我要自闭啦！";
        }
    }
</script>
</body>
</html>